<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>proc (Spec::DSL::CompositeProcBuilder)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File vendor\plugins\rspec/lib/spec/dsl/composite_proc_builder.rb, line 8</span>
      <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">proc</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">error_handler</span>)
        <span class="ruby-identifier">parts</span> = <span class="ruby-keyword kw">self</span>
        <span class="ruby-identifier">errors</span> = []
        <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
          <span class="ruby-identifier">result</span> = <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
            <span class="ruby-keyword kw">begin</span>
              <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">UnboundMethod</span>)
                <span class="ruby-identifier">part</span>.<span class="ruby-identifier">bind</span>(<span class="ruby-keyword kw">self</span>).<span class="ruby-identifier">call</span>
              <span class="ruby-keyword kw">else</span>
                <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">part</span>)
              <span class="ruby-keyword kw">end</span>
            <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
              <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">error_handler</span>
                <span class="ruby-identifier">error_handler</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">e</span>)
              <span class="ruby-keyword kw">else</span>
                <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
              <span class="ruby-keyword kw">end</span>
            <span class="ruby-keyword kw">end</span>
          <span class="ruby-keyword kw">end</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-identifier">result</span>
        <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">end</span></pre>
</body>
</html>